package ar.uade.edu.fain.ad.server.dao.jpa;

import ar.uade.edu.fain.ad.server.business.CierreCaja;
import ar.uade.edu.fain.ad.server.dao.CierreCajaDAO;
import ar.uade.edu.fain.ad.server.dao.entity.CajaEntity;
import ar.uade.edu.fain.ad.server.dao.entity.CierreCajaEntity;

public class CierreCajaJpaDAO 
		extends GenericJpaDAO<CierreCaja, CierreCajaEntity, Long> 
		implements CierreCajaDAO {

	public CierreCajaJpaDAO() {
		super(CierreCajaEntity.class);
	}

	@Override
	protected CierreCajaEntity toEntity(final CierreCaja business) {
		final CierreCajaEntity entity = new CierreCajaEntity();
		entity.setId(business.getId());
		entity.setFecha(business.getFecha());
		entity.setTotalCupones(business.getTotalCupones());
		entity.setTotalEfectivo(business.getTotalEfectivo());
		entity.setCantidadCupones(business.getCantidadCupones());
		final CajaEntity cajaEntity = (CajaEntity) 
				getSession().get(CajaEntity.class, business.getCaja().getId());
		entity.setCaja(cajaEntity);
		return entity;
	}

	@Override
	protected CierreCaja toBusiness(final CierreCajaEntity entity) {
		final CierreCaja business = new CierreCaja();
		business.setId(entity.getId());
		business.setCantidadCupones(entity.getCantidadCupones());
		business.setTotalCupones(entity.getTotalCupones());
		business.setTotalEfectivo(entity.getTotalEfectivo());
		business.setFecha(entity.getFecha());
		return business;
	}
	
	
}
